#ifndef WIDGETTREE_H
#define WIDGETTREE_H

#include <DefineLibUiQt.h>
#include <QtWidgets/QWidget>
#include <QtWidgets/QTreeWidgetItem>
#include <EItem.h>
#include <EControllerQtTree.h>

namespace Ui {
class WidgetTree;
}

class LIB_UI_QT_DLL WidgetTree : public QWidget
{
    Q_OBJECT
public:
    explicit WidgetTree(QWidget *parent = nullptr);
    ~WidgetTree();

    virtual void showEvent(QShowEvent* event);

    //get the root item which will be used by outer code.
    QTreeWidgetItem* getRootItem();

    EControllerPtr getController();
    void setController(EControllerQtTreePtr controller);

    long getTag();
    
    void refresh();
    //expand all tree item
    void expandAll();
    //hiden all top buttons
    void hideTopButtons();
signals:
	void signalTreeAdd(QTreeWidgetItem* parentItem);
	void signalTreeRefresh();
    void signalSelectItem(QTreeWidgetItem *current, QTreeWidgetItem *previous);
    void signalDeleteItem(QTreeWidgetItem* current);

    /***/
    void signalSelectItemBase(EItemPtr ibp);
    void signalDisSelectItemBase(EItemPtr ibp);
public slots:
    void slotButtonAdd(bool value);
    void slotButtonCopy(bool value);
    // void slotButtonPaste(bool value);
    void slotButtonDelete(bool value);
    void slotButtonRefresh(bool value);
    void slotSelectItem(QTreeWidgetItem *current, QTreeWidgetItem *previous);
    void slotExpanded(QModelIndex index);
private:
    Ui::WidgetTree *ui;
    QTreeWidgetItem* m_rootItem;
    EControllerQtTreePtr m_controllerTree;
    bool m_firstShowEvent = true;

};

#endif // WIDGETTREE_H
